<?php

namespace Tests\Feature;

use App\Services\AirportsSearchService;
use App\Services\ElasticsearchService;
use App\Services\SearchServiceInterface;
use Elastic\Elasticsearch\ClientBuilder;
use Illuminate\Support\Collection;
use Tests\TestCase;

class AirportsSearchServiceTest extends TestCase
{
    private SearchServiceInterface $service;
    public function setUp(): void
    {
        $client = ClientBuilder::create()
            ->setHosts(['localhost:9200'])
            ->build();

        $elasticsearchService = new ElasticsearchService($client);
        $this->service = new AirportsSearchService($elasticsearchService);

        parent::setUp();
    }

    public function testSearch()
    {
        $result = $this->service->search('dlm');

        $this->assertInstanceOf(Collection::class, $result);
    }
}
